//
//  SchoolDetailAdressTableViewCell.swift
//  HoneyBee
//
//  Created by point on 2018/6/2.
//  Copyright © 2018年 point. All rights reserved.
//

import UIKit

class SchoolDetailAdressTableViewCell: UITableViewCell {
    
    fileprivate lazy var addressLabel =  UILabel.init(UIColor.init(hex: "333333")!, 14, "详细地址:异常的地址")
    
    fileprivate lazy var localImg = UIImageView(imgName: "dingwei")
    

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

// MARK:- 显示数据
extension SchoolDetailAdressTableViewCell {
    func configModel(model:SchoolDetailModel) {
        let str:NSString = model.address as NSString
        let arr = str.components(separatedBy: ";")
        if arr.count == 9 {
             let str = "详细地址:" + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8]
            addressLabel.attributedText = NSAttributedString.getAttributedString(text: str, index: 5, aC: UIColor.black, bC: UIColor.init(hex: "333333")!, aF: 15, bF: 14, line: false, lineSpacing: 3)
        }
       
    }
}

extension SchoolDetailAdressTableViewCell {
    fileprivate func setupUI(){
        contentView.addSubview(addressLabel)
        contentView.addSubview(localImg)
        
        localImg.snp.makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 18, height: 18))
            make.centerY.equalTo(addressLabel)
            make.left.equalTo(contentView).offset(7.5)
        }
        
        addressLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(contentView).jOffset(-2.5)
            make.left.equalTo(contentView).jOffset(30)
            make.right.equalTo(contentView).jInset(30)
        }
        addressLabel.numberOfLines = 0
        
        let oneLineView = UIView()
        contentView.addSubview(oneLineView)
        oneLineView.backgroundColor = UIColor.init(hex: "eeeded")
        oneLineView.snp.makeConstraints { (make) in
            make.jHeight(5)
            make.left.right.equalTo(contentView)
            make.bottom.equalTo(contentView)
        }
    }
    
    
}
